import {generateUUID} from "@/utils";

/**
 * token
 */

export const TOKEN = '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'

/**
 * 默认用户名
 */
export const USERNAME = 'NingLiu1998'

/**
 * 默认仓库
 */
export const REPO_NAME = 'NdocsWeb'

/**
 * 默认分支
 */
export const DEFAULT_BRANCH = 'main'


/**
 * 仓库类型
 * github => gh
 * npm => npm
 */
const REPO_TYPE = 'gh'


/**
 * CND 源
 * 1、https://cdn.staticaly.com
 * 2、https://cdn.jsdelivr.net
 */
const CND_SOURCE = 'https://cdn.jsdelivr.net'


/**
 * 生成CND
 */
export const CND = `${CND_SOURCE}/${REPO_TYPE}`


export const createFilePath = () => {
  let date = new Date()
  return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
}


export const getFileName = (fileName: string) => {
  let strings = fileName.split(".");
  return strings.length < 1 ? generateUUID() : `${generateUUID()}.${strings[strings.length - 1]}`
}

export const covertCDN = (path: String) => `${CND}/${USERNAME}/${REPO_NAME}@${DEFAULT_BRANCH}/${path}`
